package com.cet.base;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @program: cet-practice
 * @description:
 * @author: 陈恩涛
 * @create: 2023-03-26 11:17
 **/
public class LockSupportTest {
    public static void main(String[] args) {
        final Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t ----------come in");
            LockSupport.park();
            System.out.println(Thread.currentThread().getName() + "\t ---------- 被唤醒");
        }, "t1");
        t1.start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(() -> {
            LockSupport.unpark(t1);
            System.out.println(Thread.currentThread().getName() + "\t ----------发出通知");
        }, "t2").start();

    }
}
